package org.framework.customutil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @Title: ContextHolderUtils.java .<br>
 * @Package org.framework.customutil .<br>
 * @Description: 上下文工具类,该类需要在xml文件里面初始化 .<br>
 * @author 郑成功 .<br>
 * @email a876459952@qq.com .<br>
 * @date 2018-6-7 下午8:44:17.<br>
 * @version V1.0.<br>
 */
public class ContextHolderUtils {
	
	/**
	 * @Description: pringMvc下获取request .<br>
	 * @author 郑成功 .<br>
	 * @date 2018-6-7 下午8:44:47.<br>
	 */
	public static HttpServletRequest getRequest() {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
		return request;

	}
	
	/**
	 * @Description: SpringMvc下获取session .<br>
	 * @author 郑成功 .<br>
	 * @date 2018-6-7 下午8:45:31.<br>
	 */
	public static HttpSession getSession() {
		HttpSession session = getRequest().getSession();
		return session;

	}

}
